package com.library.rest.rxjava;

/**
 * 在此写用途
 *
 * @author: zhiwei
 * @date: 2017-07-02 20:53
 * @version: 9.1.0
 */
public abstract class AbstractErrorHandler {
    private AbstractErrorHandler mSuccessor;

    public AbstractErrorHandler(AbstractErrorHandler successor) {
        mSuccessor = successor;
    }

    /**
     * 错误处理
     * @param code
     * @param message
     */
    public void handle(int code, String message) {
        if (!doHandle(code, message) && mSuccessor != null) {
            mSuccessor.handle(code, message);
        }
    }

    protected abstract boolean doHandle(int code, String message);
}
